Skip to content

Import zod/v3 and allow zod 4 as a dependency range - #309

Open
dtheurer-control4 wants to merge 1 commit into
modelcontextprotocol:mainfrom
dtheurer-control4:fix/zod-v3-subpath
Open

dtheurer-control4 wants to merge 1 commit into
modelcontextprotocol:mainfrom
dtheurer-control4:fix/zod-v3-subpath

Conversation

@dtheurer-control4

Copy link
Copy Markdown

Problem

The package imports the bare "zod" root in 13 source files and declares zod: ^3.25.67 as a hard dependency. The root export changes between Zod majors, and the hard dependency means any project that uses Zod 4 (for example the MCP TypeScript SDK) installs a second, nested Zod 3 copy of this package's dependency. Projects that run npm audit then see advisories that affect zod <4.6.6 on the nested copy, with no way to resolve them except a package-manager override.

Change

  • Import from "zod/v3" instead of "zod" (the subpath exists since Zod 3.25.0 and is shipped by Zod 4), as recommended in the Zod library-author guide (https://zod.dev/library-authors). The schemas stay Zod 3 schemas, so zod-to-json-schema keeps receiving the input it expects.
  • Widen the dependency range to ^3.25.67 || ^4.0.0.
  • yarn.lock updated; with the wider range yarn resolves 4.6.7 and prints a peer warning for zod-to-json-schema (peer ^3.24.1), which the maintainers may prefer to handle by keeping the resolution on 3.25.x.

Testing

Run with npm in a scratch checkout (not the repo's yarn setup): with zod 3.25.76 and with zod 4.6.7 the Jest results are identical (59 passed, 8 failed, 1 pre-existing tsc error in src/node/sign.ts; the failures are unrelated to Zod in my environment). With the old bare import under Zod 4, one more test fails. I did not run the full upstream CI, so please treat the unrelated failures as environment noise until CI confirms.

Happy to adjust (for example to make Zod a peer dependency instead).

🤖 Generated with Claude Code

The package imports the bare "zod" root, whose API changes between majors, and declares
zod ^3.25.67 as a hard dependency, so a consumer on zod 4 (for example the MCP TypeScript
SDK) installs a second, nested zod 3 copy of this package's dependency.

Import from "zod/v3" (available since zod 3.25.0 and shipped by zod 4) and widen the
range to ^3.25.67 || ^4.0.0, as the Zod library-author guide recommends. zod-to-json-schema
keeps receiving v3 schemas. yarn.lock updated (resolves 4.6.7 now that the range allows it).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant